package com.knowswift.common.utils;

import java.util.*;

public class CollectionUtil {

    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }

    public static boolean isEmpty(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }

    public static boolean identical(Collection<?> collection, Collection<?> other) {

        if (collection == null) {
            return other == null;
        } else if (other == null || collection.size() != other.size()) {
            return false;
        }
        for (Object o : collection) {
            boolean flag = other.stream().noneMatch(o::equals);
            if (flag) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("12");
        list.add("13");
        HashSet<String> list1 = new HashSet<>();
        list1.add("13");
        list1.add("12");
        boolean identical = identical(list, list1);
        System.out.println(identical);
    }

}
